package com.hong.arithmetic.base;

/**
 * 快速排序
  */
public class FastSort {

    public static void main(String[] args) {
        int[] arr = { 11, 75, 65, 36, 23, 22, 76, 1, 12, 8, 6, 0, -1, 22 };
        System.out.println("排序前："+arr);
        sort(arr,0,arr.length-1);
    }

    private static void sort(int[] arr,int low,int high){
        //临时变量
        int temp = arr[low];
        //开始坐标
        int start = low;
        //结束坐标
        int end = high;
        while (start<end){
            while ((start<end) && (arr[end]>temp)) {
                end--;
            }

            while ((start<end) && (arr[start]<temp)) {
                start--;
            }

            if ((arr[start]==arr[end])&&(start<end)) {
                start++;
            } else {
                int temp2 = arr[start];
                arr[start] = arr[end];
                arr[end] = temp2;
            }
        }


    }
}
